<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>命名路由</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <!-- 命名路由 显示 -->
        <router-view></router-view>
        <router-view name="one"></router-view>
        <router-view name="two"></router-view>
    </div>

    <script>
        const My = { template: `<div>默认组件显示</div>` };
        const MyOne = { template: `<div>name组件一</div>` };
        const MyTwo = { template: `<div>name组件二</div>` };

        const routes = [{
            path: '/',
            components: {
                // 展示默认页面
                default: My,
                one: MyOne,
                two: MyTwo
            }
        }
        ];
        const router = new VueRouter({
            routes,
        })
        const app = new Vue({
            el: "#app",
            router,
        })
    </script>
</body>

</html>